﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;
using DAL;
using System.Text;

public class baby : IHttpHandler
{
    BabyDAL BB = new BabyDAL();
    public void ProcessRequest(HttpContext context)
    {
        string functionname = context.Request.Form["functionname"].ToString();
        switch (functionname)
        {   //查询宝宝记事本
            case "jhy_baby_notepad_query": jhy_baby_notepad_query(); break;
            //宝宝记事本添加记录
            case "jhy_baby_notepad_add": jhy_baby_notepad_add(); break;
            //宝宝记事本修改记录
            case "jhy_baby_notepad_edit": jhy_baby_notepad_edit(); break;
            //宝宝记事本删除记录
            case "jhy_baby_notepad_delete": jhy_baby_notepad_delete(); break;
            //宝宝记事本操作
            case "jhy_baby_notepad_done": jhy_baby_notepad_done(); break;

        }
    }

    #region 查询宝宝记事本
    public void jhy_baby_notepad_query()
    {
        string note_table = HttpContext.Current.Request.Form["note_table"].ToString();
        DataSet ds = new DataSet();
        QXHelper QX = new QXHelper();
        ds = BB.jhy_baby_notepad_query();
        if (note_table == "0")
        {
            HttpContext.Current.Response.Write(QX.LayuiTableJson(ds.Tables[0]));
        }
        else {
            HttpContext.Current.Response.Write(QX.LayuiTableJson(ds.Tables[1]));
        }
    }
    #endregion
    #region 宝宝记事本添加记录
    public void jhy_baby_notepad_add()
    {
        string note_content = HttpContext.Current.Request.Form["note_content"].ToString();
        string note_userid = HttpContext.Current.Request.Form["note_userid"].ToString();
        bool b = BB.jhy_baby_notepad_add(note_content, note_userid);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 宝宝记事本修改记录
    public void jhy_baby_notepad_edit()
    {
        string note_id = HttpContext.Current.Request.Form["note_id"].ToString();
        string note_content = HttpContext.Current.Request.Form["note_content"].ToString();
        bool b = BB.jhy_baby_notepad_edit(note_id, note_content);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 宝宝记事本删除记录
    public void jhy_baby_notepad_delete()
    {
        string note_id = HttpContext.Current.Request.Form["note_id"].ToString();
        bool b = BB.jhy_baby_notepad_delete(note_id);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion
    #region 宝宝记事本操作
    public void jhy_baby_notepad_done()
    {
        string note_id = HttpContext.Current.Request.Form["note_id"].ToString();
        string note_state = HttpContext.Current.Request.Form["note_state"].ToString();        
        bool b = BB.jhy_baby_notepad_done(note_id, note_state);
        if (b)
        {
            HttpContext.Current.Response.Write("true");
        }
        else
        {
            HttpContext.Current.Response.Write("false");
        }
    }
    #endregion





    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}